<template>
  <div class="box">
    <h2 ref="title">当前求和为:{{ n }}</h2>
    <button @click="add">点击加1</button>
  </div>
</template>

<script>
export default {
  name: 'RefHTML',
  data() {
    return {
      n: 1
    }
  },
  methods: {
    add() {
      this.n++,
        console.log(this.$refs.title);
    }
  },
}
</script>

<style scoped>
.box {
  background-color: #ccc;
}
</style>